//////////////////////////////////////////////////////////////////////////////////
//
//	avamods redirect
//		- Version 1.0
//		- 08.09.2006
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
//    - Menu for the AvaMods server that
//	allows clients to easily connect to the other
//	avamods dod server... (no longer used!)
//
//////////////////////////////////////////////////////////////////////////////////
//
// Changelog:
//
//    - 08.09.2006 Version 1.0
//  	  Initial release
//
//////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>

new p_address, p_join, p_delay

public plugin_init()
{
	register_plugin("avamods redirect","1.0","diamond-optic")
	
	register_cvar("avamods_redirect_stats", "1.0", FCVAR_SERVER|FCVAR_SPONLY)
	
	p_address = register_cvar("avamods_redirect_ip","8.2.120.146:27015")
	p_join = register_cvar("avamods_redirect_msgjoin","1")
	p_delay = register_cvar("avamods_redirect_msgdelay","90")
	
	register_clcmd("say /servers","funcServers",0,"Show other servers")
	register_clcmd("say_team /servers","funcServers",0,"show other servers")
	
	register_menucmd(register_menuid("avamods_server_menu"),1023,"ServerMenuChoice") 
}

public client_putinserver(id)
{
	if(!is_user_bot(id) && is_user_connected(id) && get_pcvar_num(p_join) == 1) 
		set_task(get_pcvar_float(p_delay),"ShowMsg",id)
}

public ShowMsg(id)
{
	if(!is_user_bot(id) && is_user_connected(id) && get_pcvar_num(p_join) == 1) 
		client_print(id,print_chat,"To switch to the other AvaMods server, type /servers in the chat...")
}

public funcServers(id)
{	
	if(!is_user_bot(id) && is_user_connected(id))	
		show_menu(id,(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9),"avamods server menu^n^n 1.  Connect to other server^n 2.  Stay here",-1,"avamods_server_menu") 

	return PLUGIN_HANDLED
}

public ServerMenuChoice(id, key) 
{ 
   if(is_user_connected(id) && is_user_alive(id))
	{	
	switch(key)
		{
		case 0: 
			{
			new address[24]
			get_pcvar_string(p_address,address,23)
			
			client_cmd(id,"connect %s",address)
			}
		case 1: return PLUGIN_HANDLED
		}
	}
	
   return PLUGIN_CONTINUE
}
